<div class="col-md-4" style="padding-right: 0px; padding-left: 30px;">

    <if condition="CONTROLLER_NAME eq 'Index' && ACTION_NAME eq 'index' ">
        <aside id="posts-3">
            <div class="widget">
                <h4 class="title">个人专区</h4>
                <div class="content" style="height:108px;">
                    <div class="account-img">
                        <img alt="Cocolait" src="__HOME__/images/_20180104221459.jpg" style="width: 100px;height: 100px;">
                    </div>
                    <div class="account-c">
                        <a href="javascript:;" class="account">Kyle</a>
                        <a href="javascript:;" class="signature" title="每天多做一点点,开心多一点..">每天多做一点点,开心多一点..</a>
						<a href="javascript:;" title="邮箱" class="links">1577697795@qq.com</a>
                        <a href="#" title="githup" class="links" target="_blank"></a>
                    </div>

                </div>

            </div>
        </aside>
    </if>

    <aside id="posts-1">
        <div class="hot-article">
            <div class="panel-heading">
                <span>浏览排行</span>
            </div>
            <ul class="list-group">
                <?php $titleData = M('article')->order("hits DESC")->field('aid,title,hits')->limit(6)->select();?>
                <foreach name="titleData" item="vv">
                    <li class="list-group-item">
                      <span class="post-title">
                        <a href="/a/{$vv['aid']}.html" title="{$vv['title']}">{:msubstr($vv['title'],0,25)}</a>
                      </span>
                      <span class="badge">{$vv['hits']}</span>
                    </li>
                </foreach>
            </ul>
        </div>
    </aside>

    <aside id="posts-2">
        <div class="widget">
            <h4 class="title">标签云</h4>
            <div class="tag-cloud">
                <?php 
					$tagsData = M('tags')
								->join(' cp_article_tags on cp_tags.tid = cp_article_tags.cp_tags_tid ','left')
								->group(' cp_article_tags.cp_tags_tid ')
								->order(' tags_num desc ')
								->getField(' cp_tags.tid,cp_tags.tname,count(cp_article_tags.cp_article_aid) as tags_num ');
				
				?>
                <foreach name="tagsData" item="t">
                    <a href="/st/{$t['tid']}.html">{$t.tname}(<span>{$t.tags_num}</span>)</a>
                </foreach>
            </div>

        </div>

    </aside>
	
	<!--<aside id="posts-4">-->
        <!--<div class="widget">-->
            <!--<h4 class="title" title="点击添加">开源项目<small onclick="showAdd()">+</small></h4>-->
            <!--<div class="remark">-->
                <!--<ul>-->
					<!--<?php-->
						<!--$cheats = M('cheat')->where(' status=1 ')->order('id desc')->limit(10)->select();-->
					<!--?>-->
					<!--<foreach name="cheats" item="cheat">-->
						<!--<if condition="$cheat['title']">-->
						<!--<li><a target="_bank" href="{$cheat.url}">{$cheat.title}</a></li>-->
						<!--</if>-->
					<!--</foreach>-->
				<!--</ul>-->
            <!--</div>-->

        <!--</div>-->
		<!--<div class="hide" id="showAdd">-->
		<!--<form>-->
			<!--<div class="form-group" style="margin-left:15px;margin-top:5px;">-->
				<!--<label for="title">标题</label>-->
				<!--<input type="text" name="title" class="form-control" id="cheat-title" style="width:95%;" value='' placeholder="请输入标题">-->
			<!--</div>-->
			<!--<div class="form-group" style="margin-left:15px;margin-top:5px;">-->
				<!--<label for="url">github/官网地址</label>-->
				<!--<input type="text" name="url" class="form-control" id="cheat-url" style="width:95%;" value='' placeholder="请输入网站地址">-->
			<!--</div>-->
			<!--<center><button type="button" onclick="formSubmit()" class="btn btn-default">提交</button></center>-->
			<!--</form>-->
		<!--</div>-->
    <!--</aside>-->

</div>
<script type="text/javascript">
	function showAdd(){
		layer.open({
		    type: 1,
			title:'添加即展示哦！',
		    skin: 'layui-layer-rim', //加上边框
		    area: ['420px', '240px'], //宽高
		    content: $("#showAdd").html()
		});
	}
	function formSubmit(){
		var title = document.getElementsByName('title')[1].value;
		var url   = document.getElementsByName('url')[1].value;
		if(title =='' || url==''){
			return layer.alert('请输入标题或链接！')
		}
		if(!/[\u4e00-\u9fa5A-Za-z]/.test(title)) {
			return layer.alert('标题为中文和字母！');
		}
		if(!/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(url)){
			return layer.alert('地址格式错误！');
		}
		$.ajax({
                url: "{:U('index/cheat_save')}",
                method: 'post',
                dataType: 'json',
                data:     {
                    'title' : title,
                    'url' : url,
                },
                success: function(data) {
					if(data.code =='ok'){
						layer.alert('添加成功！');
						layer.closeAll();
						setInterval(function () { $("#posts-4").load(location.href + " #posts-4"); }, 5000);
					}
				},
				error  : function(data) {}
			})
	}
</script>